#!/usr/bin/python
# Copyright (C) 2005-2006 Frederic Back <fredericback@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.

from threading import enumerate
import gtk

#------------------- import mezogis
from mezoGISlib._guicore import PGButler
from mezoGISlib._plugins import Argument, UserPlugin
from mezoGISlib import _pluginloader        # load and execute external python plugins
from mezoGISlib import _project_io          # functions to load and save project files
from mezoGISlib import _mapping_tools

#------------------ parse command line parameters to modify Options static class
from mezoGISlib._options import Options
from optparse import OptionParser
parser = OptionParser("usage: %prog [options]",version="mezoGIS %s"%Options.version)
parser.add_option("-v", "--verbose", action="store_true", dest="verbose")
(Options, args) = parser.parse_args()

#---------------------- run
def main():
    PGButler.instance.run()
    gtk.gdk.threads_init()

    try: gtk.gdk.threads_enter()
    except: gtk.threads_enter()

    gtk.main()

    try: gtk.gdk.threads_leave()
    except: gtk.threads_leave()

    PGButler.instance.die() # kill open threads
    print enumerate()

if __name__ == "__main__":
    main()
